﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using OgilvyOne.BLL;
using OgilvyOne.Model;

/// <summary>
/// 前台页面基类,可获取公共导航,当前会员状态/信息等
/// </summary>
public class FrontBasePage : BasePage
{
    protected MenuModel menuModel;

    protected override void OnLoad(EventArgs e)
    {
        menuModel = new MenuModel(GetColumnId());
        base.OnLoad(e);
    }

    public FrontBasePage()
    {
        
    }
    /// <summary>
    /// 当前登录会员信息
    /// </summary>
    /// <returns></returns>
    //protected MemberInfoModel GetSessionMemberInfo()
    //{
    //    return (MemberInfoModel)new MemberInfoBll().GetLoginMemberInfo();
    //}
    
    /// <summary>
    /// 会员是否登录
    /// </summary>
    /// <returns></returns>
    protected bool isLogin()
    {
        //if (GetSessionMemberInfo() == null)
        //    return false;
        return true;
    }

    public string GetBanner()
    {
        return menuModel.GetColumntTitleImg();
    }
    public virtual string GetMeta()
    {

        string title ="<title>" + menuModel.GetColumn().Classname + menuModel.GetMenuListTitle() + " - " + ConConstants.WEB_NAME + "</title>\n";
        title = "";
        return title + menuModel.GetColumntSEO(true);
    }

    protected virtual int GetColumnId()
    {
        return ConConstants.HOME_ID;
    }
    
    /// <summary>
    /// 是否本地提交，不准远程提交
    /// </summary>
    /// <returns></returns>
    protected bool IsCofco()
    {
        if (Request.Params["token"] != null && Request.Params["token"] != "")
        {
            string ptoken = Request.Form["token"];
            if (ptoken == null || ptoken == "")
            {
                ptoken = Request.QueryString["token"];
            }
            HttpCookie Cookie = System.Web.HttpContext.Current.Request.Cookies["token"];
            if (Cookie != null)
            {
                if (Cookie.Value == ptoken)
                {
                    //Cookie.Expires = DateTime.Now.AddDays(-1);
                    //System.Web.HttpContext.Current.Response.Cookies.Add(Cookie);
                    return true;
                }
            }
            
        }
        return false;
    }
}
